﻿using System;
using System.Collections.Generic;
using IQToolkit;
using IQToolkit.Data;
using Infrastucture.Factories;
using TimeSplicerModule.DataModels;
using TimeSplicerModule.DomainModels;

namespace TimeSplicerModule.Factories
{
    public interface IProjectRoleFactory : Infrastucture.Factories.IFactory<ProjectRoleDataModel, ProjectRoleModel>
    {
        ProjectRoleModel CreateNew(Guid applicationPermissionGuid, int heirarchy, ApplicationPermissionModel permission, List<ApplicationPermissionModel> applicationPermissions);
    }

    public class ProjectRoleFactory : Factory<ProjectRoleDataModel, ProjectRoleModel>, IProjectRoleFactory
    {
        public ProjectRoleFactory(DbEntityProvider provider, IEntityTable<ProjectRoleDataModel> db)
            : base(provider, db)
        {

        }

        public ProjectRoleModel CreateNew(Guid applicationPermissionGuid, int hierarchy, ApplicationPermissionModel permission, List<ApplicationPermissionModel> applicationPermissions)
        {
            return new ProjectRoleModel
            {
                ApplicationPermissionGuid = applicationPermissionGuid,
                Hierarchy = hierarchy,
                Permission = permission,
                ApplicationPermissions = applicationPermissions
            };
        }
    }
}
